package sinochem.bpmrefactor.rabbitlistener.cofig.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * 动态数据源决策
 * @author : jiagang
 * @date : Created in 2021/9/30 10:13
 */
public class DynamicDataSource extends AbstractRoutingDataSource {

    private static final Logger LOGGER = LoggerFactory.getLogger(DynamicDataSource.class);

    @Override
    protected Object determineCurrentLookupKey() {
        String datasource = DataSourceContextHolder.getDbType();
        LOGGER.debug("使用数据源 {}", datasource);
        return datasource;
    }
}
